//
//  CrazyChatCustomImageCell.m
//  webSocket
//
//  Created by 马军凯 on 2019/2/18.
//  Copyright © 2019年 ZH. All rights reserved.
//

#import "CrazyChatCustomImageCell.h"
#import "FLAnimatedImageView+WebCache.h"

@interface CrazyChatCustomImageCell ()

@property (nonatomic, strong) UIImageView *customHeadImageView; //头像
@property (nonatomic, strong) UIView *customBackView; //背景
@property (nonatomic, strong) FLAnimatedImageView *customImageView; //图片

@end

@implementation CrazyChatCustomImageCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

+ (instancetype)cellWithTableView:(UITableView *)tableView {
    static NSString *identifier = CrazyChatCustomImageIdentifier;
    
    //缓存中取
    CrazyChatCustomImageCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    
    //创建
    if (!cell) {
        cell = [[CrazyChatCustomImageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor clearColor];
        //头像
        self.customHeadImageView = [[UIImageView alloc] init];
        self.customHeadImageView.frame = CGRectMake(15, 10, 40, 40);
        [self.contentView addSubview:self.customHeadImageView];
        //背景
        self.customBackView = [[UIView alloc] init];
        self.customBackView.frame = CGRectMake(60, 10, 100, 100);
        [self.contentView addSubview:self.customBackView];
        //图片
        self.customImageView = [[FLAnimatedImageView alloc] init];
        self.customImageView.frame = self.customBackView.bounds;
        [self.customBackView addSubview:self.customImageView];
    }
    return self;
}

//赋值
- (void)setCellValueWithHeadURL:(NSString *)headURL picURL:(NSString *)picURL {
    //头像
    [self.customHeadImageView sd_setImageWithURL:[NSURL URLWithString:headURL] placeholderImage:CRAZY_DEFAULT_HEADIMAGE];
    //图片
    [self.customImageView sd_setImageWithURL:[NSURL URLWithString:picURL] placeholderImage:CRAZY_DEFAULT_LOADIMAGE];
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
